package com.demo.framework.widget;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

/**
 * 
 * @ClassName: ToastMessage
 * @Description: TODO(显示 Toast)
 * @author 谢云腾
 * @date 2013-3-22 上午11:12:53
 * @version 1.0
 */
public class ViewToastUtil {

    private static Toast toast = null;

    /**
     * 
    *
    * @Title: showCenterMessage 
    * @Description: TODO(显示toast  显示在Screen 中间) 
    * @param @param context
    * @param @param msg    设定文件 
    * @return void    返回类型 
    * @throws
     */
    public static void showCenterMessage(Context context, String msg) {
        if (toast != null) {
            toast.cancel();
            toast = null;
        }
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    public static void showCenterMessage(Context context, int res) {
        if (toast != null) {
            toast.cancel();
            toast = null;
        }
        toast = Toast.makeText(context, res, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

    
    /**
     * 
    *
    * @Title: showMessage 
    * @Description: TODO(显示Toast ) 
    * @param @param context
    * @param @param msg    设定文件 
    * @return void    返回类型 
    * @throws
     */
    public static void showMessage(Context context, String msg) {
        if (toast != null) {
            toast.cancel();
            toast = null;
        }
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        toast.show();
    }

    public static void showMessage(Context context, int res) {
        if (toast != null) {
            toast.cancel();
            toast = null;
        }
        toast = Toast.makeText(context, res, Toast.LENGTH_SHORT);
        toast.show();
    }
}
